<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Job extends MY_Luckydog
{
	public function __construct()
	{
		parent::__construct();
        
        $this->load->model('luckydog/Job_model', 'Job');
	}

/**
 * 招聘
 * @return [type] [description]
 */
    public function index(){
        $_SESSION['v_menu'] = 'Job';
        $jobList = $this->Job->getJobList();
        $data = array(
            'jobList'=>$jobList,
            );
        $this->load->view("/luckydog/job/index", $data);
    }

    public function textures()
    {
        $id = $this->input->get("id",true)?$this->input->get("id",true):"";
        if ($login_status === FALSE){
            header("Location:login");
        }
        $_SESSION['v_menu'] = 'Headhunt';
        $data = array();
        if(!empty($id)){
            $jobInfo = $this->Job->getJobInfobyID($id);
            $data["jobInfo"] = $jobInfo;
        }
    	$this->load->view("/luckydog/job/textures", $data);
    }



    //编辑新闻
    public function edit(){
        $id = $this->input->post("id",true) ? $this->input->post("id",true) : 0;
        $job_name = $this->input->post("job_name",true) ? $this->input->post("job_name",true) : "";
        $sort_order = $this->input->post("sort_order",true) ? $this->input->post("sort_order",true) : "";
        $job_intro = $this->input->post("job_intro",true) ? $this->input->post("job_intro",true) : "";
        $data = array(
            "job_name"=>$job_name,
            "job_intro"=>$job_intro,
            "sort_order"=>$sort_order,
        );
        if(empty($id)){
            $data['add_time']=time();
        }
        $res = $this->Job->editJob($id,$data);
        echo $res;
    }


    //编辑上线下，删除状态
    public function delJob(){
        $id = $this->input->post("id",true) ? $this->input->post("id",true) : 0;
        $res =$this->Job->delJob($id);
        echo $res;
    }

    public function upload_cover()
    {
        $this->load->library('Upload');
        $upload = new Upload();
        $file_name =$upload->execute($_FILES['Filedata']);

        $savepath='./upload/news/'.date('Y-m-d').'/';
        $upload->set_upload_dir($savepath);
        if (!file_exists($savepath)){
            mkdir($savepath);
        }
        if(is_string($file_name))
        {
            $res=json_encode(array('code'=>1,'type'=>0,'file_name'=>$file_name));

            echo $res;
        }
        else
        {
            echo json_encode(array('code'=>-1));
        }
    }


}
/* End of file index.php */
/* Location: ./application/controllers/luckydog/index.php */